#include <iostream>
#include <atomic>

using namespace std;

int main(int argc, char *argv[])
{
    std::atomic<int> readIndex(0);
    std::atomic_init(&readIndex, 1);

    std::cout << "readIndex "<<readIndex<<std::endl;

    for (int i=0; i<10; i++) {
        std::cout << "fetch_xor: " << readIndex.fetch_xor(1) << endl;

        std::cout << "after fetch_xor readIndex "<<readIndex<<std::endl;
    }


    return 0;
}
